

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <title>Macro - LiterateCS</title>

	<link rel="icon" type="image/x-icon" href="../images/favicon.ico">
    <link rel="stylesheet" href="../bootstrap/css/readable/bootstrap.min.css" />
<link rel="stylesheet" href="../font-awesome/css/font-awesome.min.css">
<link rel="stylesheet" href="../sidebar/sidebar.min.css" />
<link rel="stylesheet" href="../css/book.min.css" />
<link rel="stylesheet" href="../syntax-highlight/solarized-light.min.css" />
<link rel="stylesheet" href="../mermaid/mermaid.css" />

</head>

<body>
    
    <nav class="navbar navbar-inverse navbar-fixed-top">
        <div class="container">
            <div class="navbar-header">
                <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
                    <span class="sr-only">Toggle navigation</span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                </button>
                <a class="navbar-brand" href="#sidebar-toggle" id="sidebar-toggle">
					<span>
						<img src="../images/favicon.ico" height="24" class="hidden-sm hidden-xs" />
						<i id="sidebar-toggle-icon" class="hidden-md hidden-lg hidden-xl fa fa-angle-double-right" aria-hidden="true"></i>
						LiterateCS
					</span>
				</a>
            </div>
            <div id="navbar" class="navbar-collapse collapse">
                <ul class="nav navbar-nav">
                    <li><a href="../index.html"><i class="fa fa-home" aria-hidden="true"></i> Home</a></li>
					<li><a href="https://github.com/johtela/LiterateCS"><i class="fa fa-github" aria-hidden="true"></i> GitHub Repository</a></li>
                    <li><a href="https://www.nuget.org/packages/LiterateCS/"><i class="fa fa-download" aria-hidden="true"></i> Download</a></li>
                    <li><a href="../License.html">License</a></li>
                </ul>
            </div>
        </div>
    </nav>

    <div class="container">
        <div class="row">
            <div id="sidebar" class="col-md-3 hidden-sm hidden-xs">
                
        <div class="panel panel-default">
            <div class="panel-heading">
                <h4>On This Page</h4>
            </div>
            <div id="header-menu" class="panel-body main-menu">
                <ul></ul>
            </div>
        </div>  
        <div class="panel panel-default">
            <div class="panel-heading">
                <h4>Table of Contents</h4>
            </div>
            <div class="panel-body main-menu">
                <ul>
	<li><a href="../index.html">Home</a></li>
	<ul>
	</ul>
	<li><a href="../Introduction.html">Introduction</a></li>
	<ul>
	</ul>
	<li><a href="../LiterateCS/Options.html">Command Line Options</a></li>
	<ul>
	</ul>
	<li><a href="../LiterateCS/Program.html">Main Program</a></li>
	<ul>
	</ul>
	<li><a href="../LiterateCS/SplitPath.html">SplitPath Structure</a></li>
	<ul>
	</ul>
	<li><a href="../LiterateCS/Weaver.html">Document Weaver</a></li>
	<ul>
	</ul>
	<li><a href="../LiterateCS/MdWeaver.html">Markdown Weaver</a></li>
	<ul>
	</ul>
	<li><a href="../LiterateCS/HtmlWeaver.html">HTML Weaver</a></li>
	<ul>
	</ul>
	<li><a href="../LiterateCS/TocManager.html">TOC Manager</a></li>
	<ul>
	</ul>
	<li><a href="../LiterateCS/BlockList.html">Source Blocks</a></li>
	<ul>
	</ul>
	<li><a href="../LiterateCS/Macro.html" class="selected">Macros</a></li>
	<ul>
	</ul>
	<li><a href="../LiterateCS/BlockBuilder.html">Block Builder</a></li>
	<ul>
	</ul>
	<li><a href="../LiterateCS/HtmlBlockBuilder.html">HTML Block Builder</a></li>
	<ul>
	</ul>
	<li><a href="../LiterateCS/HtmlGenerator.html">HTML Generation</a></li>
	<ul>
	</ul>
	<li>Themes</li>
	<ul>
<ul>
	<li><a href="../LiterateCS.Theme/DirHelpers.html">Directory Utilities</a></li>
	<ul>
	</ul>
	<li><a href="../LiterateCS.Theme/Toc.html">Table of Contents Classes</a></li>
	<ul>
	</ul>
	<li><a href="../LiterateCS.Theme/PageParams.html">Page Parameters</a></li>
	<ul>
	</ul>
	<li><a href="../LiterateCS.Theme/Theme.html">Theme Base Class</a></li>
	<ul>
	</ul>
	<li><a href="../LiterateCS.Theme/LiterateException.html">Reporting Errors</a></li>
	<ul>
	</ul>
</ul>
	</ul>
	<li><a href="../FrontMatter.html">Front Matter</a></li>
	<ul>
	</ul>
	<li><a href="../TableOfContents.html">Table of Contents File</a></li>
	<ul>
	</ul>
	<li><a href="../TipsAndTricks.html">Tips &amp; Tricks</a></li>
	<ul>
	</ul>
	<li><a href="../License.html">License</a></li>
	<ul>
	</ul>
	<li><a href="../README.html">README</a></li>
	<ul>
	</ul>
	<li><a href="../Installation.html">Installation</a></li>
	<ul>
	</ul>
</ul>
            </div>
        </div>

            </div>
			<div id="contentarea" class="col-md-9 col-sm-12 col-sm-push-0 col-xs-12 col-xs-push-0">
				<ul class="pager">
	<li class="previous"><a href="../LiterateCS/BlockList.html">Previous: Source Blocks</a></li>
	<li class="next"><a href="../LiterateCS/BlockBuilder.html">Next: Block Builder</a></li>
</ul>
				<div id="static-content" class="markdown">
					<h1 id="macros">Macros</h1>
<p>Macros are sequences of blocks that can be inserted inside markdown files. They
correspond to C# <a href="https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/preprocessor-directives/preprocessor-region">regions</a>.
To create a macro, a block of code should be surrounded with the <code>#region</code>
directive. The name of the region is used as the macro name. Since macro names
should be unique, it is disallowed to have two regions with the same name.</p>
<p>The Macro class defines the data structure that is used to store macros. It
implements the <code>IEnumerable&lt;BlockList&gt;</code> interface to allow iterating though
the blocks belonging to a macro.</p>
<pre class="csharp"><code class="csharp"><span class="keyword" id="LiterateCS">namespace</span> LiterateCS
<span class="punctuation">{</span>
	<span class="keyword">using</span> LiterateCS<span class="punctuation">.</span>Theme<span class="punctuation">;</span>
	<span class="keyword">using</span> System<span class="punctuation">;</span>
	<span class="keyword">using</span> System<span class="punctuation">.</span>Collections<span class="punctuation">;</span>
	<span class="keyword">using</span> System<span class="punctuation">.</span>Collections<span class="punctuation">.</span>Generic<span class="punctuation">;</span>

	<span class="keyword" id="LiterateCS.Macro">public</span> <span class="keyword">class</span> <span class="typename">Macro</span> <span class="punctuation">:</span> <span class="typename" data-toggle="tooltip" title="System.Collections.Generic.IEnumerable<LiterateCS.BlockList>">IEnumerable</span><span class="punctuation">&lt;</span><span class="typename" data-toggle="tooltip" title="LiterateCS.BlockList"><a href="../LiterateCS/BlockList.html#LiterateCS.BlockList">BlockList</a></span><span class="punctuation">&gt;</span>
	<span class="punctuation">{</span>
</code></pre>
<h2 id="fields-of-a-macro">Fields of a Macro</h2>
<p>Macros are stored in a linked list in the same way as <a href="BlockList.html">BlockList</a>
data structures. The only pieces of data we need to store for a macro are
its name, the first block belonging to it <code>Start</code>, and the end marker block
<code>End</code>. The end marker is the first block that does <em>not</em> belong to the macro.
If the end marker is <code>null</code>, then the macro includes all the blocks until
the end of a file.</p>
<pre class="csharp"><code class="csharp">		<span class="keyword" id="LiterateCS.Macro.Name">public</span> <span class="keyword" data-toggle="tooltip" title="string">string</span> Name <span class="punctuation">{</span> <span class="keyword" data-toggle="tooltip" title="LiterateCS.Macro.Name.get">get</span><span class="punctuation" data-toggle="tooltip" title="LiterateCS.Macro.Name.get">;</span> <span class="keyword" data-toggle="tooltip" title="LiterateCS.Macro.Name.set">private</span> <span class="keyword" data-toggle="tooltip" title="LiterateCS.Macro.Name.set">set</span><span class="punctuation" data-toggle="tooltip" title="LiterateCS.Macro.Name.set">;</span> <span class="punctuation">}</span>
		<span class="keyword" id="LiterateCS.Macro.Start">public</span> <span class="typename" data-toggle="tooltip" title="LiterateCS.BlockList"><a href="../LiterateCS/BlockList.html#LiterateCS.BlockList">BlockList</a></span> Start <span class="punctuation">{</span> <span class="keyword" data-toggle="tooltip" title="LiterateCS.Macro.Start.get">get</span><span class="punctuation" data-toggle="tooltip" title="LiterateCS.Macro.Start.get">;</span> <span class="keyword" data-toggle="tooltip" title="LiterateCS.Macro.Start.set">set</span><span class="punctuation" data-toggle="tooltip" title="LiterateCS.Macro.Start.set">;</span> <span class="punctuation">}</span>
		<span class="keyword" id="LiterateCS.Macro.End">public</span> <span class="typename" data-toggle="tooltip" title="LiterateCS.BlockList"><a href="../LiterateCS/BlockList.html#LiterateCS.BlockList">BlockList</a></span> End <span class="punctuation">{</span> <span class="keyword" data-toggle="tooltip" title="LiterateCS.Macro.End.get">get</span><span class="punctuation" data-toggle="tooltip" title="LiterateCS.Macro.End.get">;</span> <span class="keyword" data-toggle="tooltip" title="LiterateCS.Macro.End.set">set</span><span class="punctuation" data-toggle="tooltip" title="LiterateCS.Macro.End.set">;</span> <span class="punctuation">}</span>
		<span class="keyword" id="LiterateCS.Macro.DefinedInFile">public</span> <span class="keyword" data-toggle="tooltip" title="string">string</span> DefinedInFile <span class="punctuation">{</span> <span class="keyword" data-toggle="tooltip" title="LiterateCS.Macro.DefinedInFile.get">get</span><span class="punctuation" data-toggle="tooltip" title="LiterateCS.Macro.DefinedInFile.get">;</span> <span class="keyword" data-toggle="tooltip" title="LiterateCS.Macro.DefinedInFile.set">set</span><span class="punctuation" data-toggle="tooltip" title="LiterateCS.Macro.DefinedInFile.set">;</span> <span class="punctuation">}</span>
</code></pre>
<p>Macros are stored in a static dictionary, whose keys are macro names.</p>
<pre class="csharp"><code class="csharp">		<span class="keyword">private</span> <span class="keyword">static</span> <span class="typename" data-toggle="tooltip" title="System.Collections.Generic.Dictionary<string, LiterateCS.Macro>">Dictionary</span><span class="punctuation">&lt;</span><span class="keyword" data-toggle="tooltip" title="string">string</span><span class="punctuation">,</span> <span class="typename" data-toggle="tooltip" title="LiterateCS.Macro"><a href="../LiterateCS/Macro.html#LiterateCS.Macro">Macro</a></span><span class="punctuation">&gt;</span> <span id="LiterateCS.Macro._macros">_macros</span> <span class="punctuation">=</span>
			<span class="keyword" data-toggle="tooltip" title="System.Collections.Generic.Dictionary<string, LiterateCS.Macro>">new</span> <span class="typename">Dictionary</span><span class="punctuation">&lt;</span><span class="keyword" data-toggle="tooltip" title="string">string</span><span class="punctuation">,</span> <span class="typename" data-toggle="tooltip" title="LiterateCS.Macro"><a href="../LiterateCS/Macro.html#LiterateCS.Macro">Macro</a></span><span class="punctuation">&gt;</span> <span class="punctuation">(</span><span class="punctuation">)</span><span class="punctuation">;</span>
</code></pre>
<p>The constructor is private. Macros should be created with the static
<code>Add</code> method.</p>
<pre class="csharp"><code class="csharp">		<span class="keyword" id="LiterateCS.Macro.Macro(string, LiterateCS.BlockList, LiterateCS.BlockList, string)" data-toggle="tooltip" title="LiterateCS.Macro.Macro(string, LiterateCS.BlockList, LiterateCS.BlockList, string)">private</span> <span data-toggle="tooltip" title="LiterateCS.Macro.Macro(string, LiterateCS.BlockList, LiterateCS.BlockList, string)">Macro</span> <span class="punctuation">(</span><span class="keyword" data-toggle="tooltip" title="string">string</span> name<span class="punctuation">,</span> <span class="typename" data-toggle="tooltip" title="LiterateCS.BlockList"><a href="../LiterateCS/BlockList.html#LiterateCS.BlockList">BlockList</a></span> start<span class="punctuation">,</span> <span class="typename" data-toggle="tooltip" title="LiterateCS.BlockList"><a href="../LiterateCS/BlockList.html#LiterateCS.BlockList">BlockList</a></span> end<span class="punctuation">,</span> 
			<span class="keyword" data-toggle="tooltip" title="string">string</span> definedInFile<span class="punctuation">)</span>
		<span class="punctuation">{</span>
			<span data-toggle="tooltip" title="string"><a href="../LiterateCS/Macro.html#LiterateCS.Macro.Name">Name</a></span> <span class="punctuation" data-toggle="tooltip" title="string">=</span> <span data-toggle="tooltip" title="string">name</span><span class="punctuation">;</span>
			<span data-toggle="tooltip" title="LiterateCS.BlockList"><a href="../LiterateCS/Macro.html#LiterateCS.Macro.Start">Start</a></span> <span class="punctuation" data-toggle="tooltip" title="LiterateCS.BlockList">=</span> <span data-toggle="tooltip" title="LiterateCS.BlockList">start</span><span class="punctuation">;</span>
			<span data-toggle="tooltip" title="LiterateCS.BlockList"><a href="../LiterateCS/Macro.html#LiterateCS.Macro.End">End</a></span> <span class="punctuation" data-toggle="tooltip" title="LiterateCS.BlockList">=</span> <span data-toggle="tooltip" title="LiterateCS.BlockList">end</span><span class="punctuation">;</span>
			<span data-toggle="tooltip" title="string"><a href="../LiterateCS/Macro.html#LiterateCS.Macro.DefinedInFile">DefinedInFile</a></span> <span class="punctuation" data-toggle="tooltip" title="string">=</span> <span data-toggle="tooltip" title="string">definedInFile</span><span class="punctuation">;</span>
		<span class="punctuation">}</span>
</code></pre>
<h2 id="ienumerable-implementation">IEnumerable Implementation</h2>
<p>Iterator is used to implement <code>IEnumerable&lt;BlockList&gt;</code> interface.</p>
<pre class="csharp"><code class="csharp">		<span class="keyword" id="LiterateCS.Macro.GetEnumerator()" data-toggle="tooltip" title="LiterateCS.Macro.GetEnumerator()">public</span> <span class="typename" data-toggle="tooltip" title="System.Collections.Generic.IEnumerator<LiterateCS.BlockList>">IEnumerator</span><span class="punctuation">&lt;</span><span class="typename" data-toggle="tooltip" title="LiterateCS.BlockList"><a href="../LiterateCS/BlockList.html#LiterateCS.BlockList">BlockList</a></span><span class="punctuation">&gt;</span> <span data-toggle="tooltip" title="LiterateCS.Macro.GetEnumerator()">GetEnumerator</span> <span class="punctuation">(</span><span class="punctuation">)</span>
		<span class="punctuation">{</span>
			<span class="keyword">for</span> <span class="punctuation">(</span><span class="keyword" data-toggle="tooltip" title="LiterateCS.BlockList">var</span> <span id="block">block</span> <span class="punctuation">=</span> <span data-toggle="tooltip" title="LiterateCS.BlockList"><a href="../LiterateCS/Macro.html#LiterateCS.Macro.Start">Start</a></span><span class="punctuation">;</span> 
				<span data-toggle="tooltip" title="LiterateCS.BlockList">block</span> <span class="punctuation" data-toggle="tooltip" title="bool">!=</span> <span class="keyword">null</span> <span class="punctuation" data-toggle="tooltip" title="bool">&amp;</span> <span data-toggle="tooltip" title="LiterateCS.BlockList">block</span> <span class="punctuation" data-toggle="tooltip" title="bool">!=</span> <span data-toggle="tooltip" title="LiterateCS.BlockList"><a href="../LiterateCS/Macro.html#LiterateCS.Macro.End">End</a></span><span class="punctuation">;</span> 
				<span data-toggle="tooltip" title="LiterateCS.BlockList">block</span> <span class="punctuation" data-toggle="tooltip" title="LiterateCS.BlockList">=</span> <span data-toggle="tooltip" title="LiterateCS.BlockList">block</span><span class="punctuation" data-toggle="tooltip" title="LiterateCS.BlockList">.</span><span data-toggle="tooltip" title="LiterateCS.BlockList"><a href="../LiterateCS/BlockList.html#LiterateCS.BlockList.Next">Next</a></span><span class="punctuation">)</span>
				<span class="keyword">yield</span> <span class="keyword">return</span> <span data-toggle="tooltip" title="LiterateCS.BlockList">block</span><span class="punctuation">;</span>
		<span class="punctuation">}</span>

		<span class="typename" data-toggle="tooltip" title="System.Collections.IEnumerator">IEnumerator</span> <span class="typename" data-toggle="tooltip" title="System.Collections.IEnumerable">IEnumerable</span><span class="punctuation">.</span><span data-toggle="tooltip" title="LiterateCS.Macro.System.Collections.IEnumerable.GetEnumerator()">GetEnumerator</span> <span class="punctuation">(</span><span class="punctuation">)</span>
		<span class="punctuation">{</span>
			<span class="keyword">return</span> <span data-toggle="tooltip" title="LiterateCS.Macro.GetEnumerator()"><a href="../LiterateCS/Macro.html#LiterateCS.Macro.GetEnumerator()">GetEnumerator</a></span> <span class="punctuation">(</span><span class="punctuation">)</span><span class="punctuation">;</span>
		<span class="punctuation">}</span>
</code></pre>
<h2 id="creating-a-macro">Creating a Macro</h2>
<p>The <code>Add</code> method is used to create a new macro. The method throws an
exception if a macro with the given name is already registered.</p>
<pre class="csharp"><code class="csharp">		<span class="keyword" id="LiterateCS.Macro.Add(string, LiterateCS.BlockList, LiterateCS.BlockList, string)" data-toggle="tooltip" title="LiterateCS.Macro.Add(string, LiterateCS.BlockList, LiterateCS.BlockList, string)">public</span> <span class="keyword" data-toggle="tooltip" title="LiterateCS.Macro.Add(string, LiterateCS.BlockList, LiterateCS.BlockList, string)">static</span> <span class="typename" data-toggle="tooltip" title="LiterateCS.Macro"><a href="../LiterateCS/Macro.html#LiterateCS.Macro">Macro</a></span> <span data-toggle="tooltip" title="LiterateCS.Macro.Add(string, LiterateCS.BlockList, LiterateCS.BlockList, string)">Add</span> <span class="punctuation">(</span><span class="keyword" data-toggle="tooltip" title="string">string</span> name<span class="punctuation">,</span> <span class="typename" data-toggle="tooltip" title="LiterateCS.BlockList"><a href="../LiterateCS/BlockList.html#LiterateCS.BlockList">BlockList</a></span> start<span class="punctuation">,</span> <span class="typename" data-toggle="tooltip" title="LiterateCS.BlockList"><a href="../LiterateCS/BlockList.html#LiterateCS.BlockList">BlockList</a></span> end<span class="punctuation">,</span>
			<span class="keyword" data-toggle="tooltip" title="string">string</span> definedInFile<span class="punctuation">)</span>
		<span class="punctuation">{</span>
			<span data-toggle="tooltip" title="string">name</span> <span class="punctuation" data-toggle="tooltip" title="string">=</span> <span data-toggle="tooltip" title="string">name</span><span class="punctuation" data-toggle="tooltip" title="string.Trim()">.</span><span data-toggle="tooltip" title="string.Trim()">Trim</span> <span class="punctuation">(</span><span class="punctuation">)</span><span class="punctuation">;</span>
			<span class="keyword">if</span> <span class="punctuation">(</span><span data-toggle="tooltip" title="System.Collections.Generic.Dictionary<string, LiterateCS.Macro>"><a href="../LiterateCS/Macro.html#LiterateCS.Macro._macros">_macros</a></span><span class="punctuation" data-toggle="tooltip" title="System.Collections.Generic.Dictionary<string, LiterateCS.Macro>.TryGetValue(string, out LiterateCS.Macro)">.</span><span data-toggle="tooltip" title="System.Collections.Generic.Dictionary<string, LiterateCS.Macro>.TryGetValue(string, out LiterateCS.Macro)">TryGetValue</span> <span class="punctuation">(</span><span data-toggle="tooltip" title="string">name</span><span class="punctuation">,</span> <span class="keyword">out</span> <span class="keyword" data-toggle="tooltip" title="LiterateCS.Macro">var</span> macro<span class="punctuation">)</span><span class="punctuation">)</span>
				<span class="keyword">throw</span> <span class="keyword" data-toggle="tooltip" title="LiterateCS.Theme.LiterateException">new</span> <span class="typename"><a href="../LiterateCS.Theme/LiterateException.html#LiterateCS.Theme.LiterateException">LiterateException</a></span> <span class="punctuation">(</span>
					<span class="keyword" data-toggle="tooltip" title="string">string</span><span class="punctuation" data-toggle="tooltip" title="string.Format(string, object, object)">.</span><span data-toggle="tooltip" title="string.Format(string, object, object)">Format</span> <span class="punctuation">(</span><span class="string" data-toggle="tooltip" title="string">&quot;Macro &#39;{0}&#39; is already defined in file: {1}\n&quot;</span> <span class="punctuation" data-toggle="tooltip" title="string">+</span> 
					<span class="string" data-toggle="tooltip" title="string">&quot;You cannot have two macros/regions with the same name.&quot;</span><span class="punctuation">,</span> <span data-toggle="tooltip" title="string">name</span><span class="punctuation">,</span> 
					<span data-toggle="tooltip" title="LiterateCS.Macro">macro</span><span class="punctuation" data-toggle="tooltip" title="string">.</span><span data-toggle="tooltip" title="string"><a href="../LiterateCS/Macro.html#LiterateCS.Macro.DefinedInFile">DefinedInFile</a></span><span class="punctuation">)</span><span class="punctuation">,</span> <span data-toggle="tooltip" title="string">definedInFile</span><span class="punctuation">,</span> 
					<span class="string" data-toggle="tooltip" title="string">&quot;https://johtela.github.io/LiterateCS/LiterateCS/Macro.html&quot;</span><span class="punctuation">)</span><span class="punctuation">;</span>
			<span class="keyword" data-toggle="tooltip" title="LiterateCS.Macro">var</span> <span id="result">result</span> <span class="punctuation">=</span> <span class="keyword" data-toggle="tooltip" title="LiterateCS.Macro">new</span> <span class="typename"><a href="../LiterateCS/Macro.html#LiterateCS.Macro">Macro</a></span> <span class="punctuation">(</span><span data-toggle="tooltip" title="string">name</span><span class="punctuation">,</span> <span data-toggle="tooltip" title="LiterateCS.BlockList">start</span><span class="punctuation">,</span> <span data-toggle="tooltip" title="LiterateCS.BlockList">end</span><span class="punctuation">,</span> <span data-toggle="tooltip" title="string">definedInFile</span><span class="punctuation">)</span><span class="punctuation">;</span>
			<span data-toggle="tooltip" title="System.Collections.Generic.Dictionary<string, LiterateCS.Macro>"><a href="../LiterateCS/Macro.html#LiterateCS.Macro._macros">_macros</a></span><span class="punctuation" data-toggle="tooltip" title="System.Collections.Generic.Dictionary<string, LiterateCS.Macro>.Add(string, LiterateCS.Macro)">.</span><span data-toggle="tooltip" title="System.Collections.Generic.Dictionary<string, LiterateCS.Macro>.Add(string, LiterateCS.Macro)">Add</span> <span class="punctuation">(</span><span data-toggle="tooltip" title="string">name</span><span class="punctuation">,</span> <span data-toggle="tooltip" title="LiterateCS.Macro">result</span><span class="punctuation">)</span><span class="punctuation">;</span>
			<span class="keyword">return</span> <span data-toggle="tooltip" title="LiterateCS.Macro">result</span><span class="punctuation">;</span>
		<span class="punctuation">}</span>
</code></pre>
<h2 id="retrieving-a-macro">Retrieving a Macro</h2>
<p>The <code>Get</code> method is used to find and return a macro. It throws
an exception, if a macro with the given name is not found.</p>
<pre class="csharp"><code class="csharp">		<span class="keyword" id="LiterateCS.Macro.Get(string, string)" data-toggle="tooltip" title="LiterateCS.Macro.Get(string, string)">public</span> <span class="keyword" data-toggle="tooltip" title="LiterateCS.Macro.Get(string, string)">static</span> <span class="typename" data-toggle="tooltip" title="LiterateCS.Macro"><a href="../LiterateCS/Macro.html#LiterateCS.Macro">Macro</a></span> <span data-toggle="tooltip" title="LiterateCS.Macro.Get(string, string)">Get</span> <span class="punctuation">(</span><span class="keyword" data-toggle="tooltip" title="string">string</span> name<span class="punctuation">,</span> <span class="keyword" data-toggle="tooltip" title="string">string</span> usedInFile<span class="punctuation">)</span>
		<span class="punctuation">{</span>
			<span data-toggle="tooltip" title="string">name</span> <span class="punctuation" data-toggle="tooltip" title="string">=</span> <span data-toggle="tooltip" title="string">name</span><span class="punctuation" data-toggle="tooltip" title="string.Trim()">.</span><span data-toggle="tooltip" title="string.Trim()">Trim</span> <span class="punctuation">(</span><span class="punctuation">)</span><span class="punctuation">;</span>
			<span class="keyword">if</span> <span class="punctuation">(</span><span class="punctuation" data-toggle="tooltip" title="bool">!</span><span data-toggle="tooltip" title="System.Collections.Generic.Dictionary<string, LiterateCS.Macro>"><a href="../LiterateCS/Macro.html#LiterateCS.Macro._macros">_macros</a></span><span class="punctuation" data-toggle="tooltip" title="System.Collections.Generic.Dictionary<string, LiterateCS.Macro>.ContainsKey(string)">.</span><span data-toggle="tooltip" title="System.Collections.Generic.Dictionary<string, LiterateCS.Macro>.ContainsKey(string)">ContainsKey</span> <span class="punctuation">(</span><span data-toggle="tooltip" title="string">name</span><span class="punctuation">)</span><span class="punctuation">)</span>
				<span class="keyword">throw</span> <span class="keyword" data-toggle="tooltip" title="LiterateCS.Theme.LiterateException">new</span> <span class="typename"><a href="../LiterateCS.Theme/LiterateException.html#LiterateCS.Theme.LiterateException">LiterateException</a></span> <span class="punctuation">(</span><span class="keyword" data-toggle="tooltip" title="string">string</span><span class="punctuation" data-toggle="tooltip" title="string.Format(string, object)">.</span><span data-toggle="tooltip" title="string.Format(string, object)">Format</span> <span class="punctuation">(</span>
					<span class="string" data-toggle="tooltip" title="string">&quot;Macro &#39;{0}&#39; is not defined. &quot;</span> <span class="punctuation" data-toggle="tooltip" title="string">+</span>
					<span class="string" data-toggle="tooltip" title="string">&quot;Make sure you have a region with that name defined in your source\n&quot;</span> <span class="punctuation" data-toggle="tooltip" title="string">+</span>
					<span class="string" data-toggle="tooltip" title="string">&quot;file and that you have included it in the input filters.&quot;</span><span class="punctuation">,</span> <span data-toggle="tooltip" title="string">name</span><span class="punctuation">)</span><span class="punctuation">,</span> 
					<span data-toggle="tooltip" title="string">usedInFile</span><span class="punctuation">,</span> <span class="string" data-toggle="tooltip" title="string">&quot;https://johtela.github.io/LiterateCS/LiterateCS/Macro.html&quot;</span><span class="punctuation">)</span><span class="punctuation">;</span>
			<span class="keyword">return</span> <span data-toggle="tooltip" title="System.Collections.Generic.Dictionary<string, LiterateCS.Macro>"><a href="../LiterateCS/Macro.html#LiterateCS.Macro._macros">_macros</a></span><span class="punctuation">[</span><span data-toggle="tooltip" title="string">name</span><span class="punctuation">]</span><span class="punctuation">;</span>
		<span class="punctuation">}</span>
	<span class="punctuation">}</span>
<span class="punctuation">}</span>
</code></pre>

				</div>
				<ul class="pager">
	<li class="previous"><a href="../LiterateCS/BlockList.html">Previous: Source Blocks</a></li>
	<li class="next"><a href="../LiterateCS/BlockBuilder.html">Next: Block Builder</a></li>
</ul>
			</div>
        </div>
    </div>
    
    <footer class="panel-footer text-center">
        <div align="center">Copyright © 2018 Tommi Johtela</div>
		<div align="right">
			<small>
				Documentation created with <a href="https://johtela.github.io/LiterateCS/">LiterateCS</a>.
			</small>
		</div>
    </footer>


    
    <script src="../bootstrap/js/jquery.min.js"></script>
    <script src="../bootstrap/js/bootstrap.min.js"></script>
    <script src="../sidebar/sidebar.js"></script>
    <script src="../syntax-highlight/syntax.js"></script>
    <script type="text/x-mathjax-config">
        MathJax.Hub.Config({
        extensions: ["jsMath2jax.js"]
        });
    </script>
    <script src='https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS_HTML'></script>
	<script src="../mermaid/mermaid.min.js"></script>
	<script>mermaid.initialize({startOnLoad:true});</script>

</body>
</html>